import java.util.ArrayList;
import java.awt.*;
// класс, инициализирующий битву
public class Battle
{
	private boolean isFinished;
	public ArrayList<Area> areas = new ArrayList<Area>();
	public int areaUnderAttack = 1;
        public Statistics stats;
	private static Battle instance;
	
	private Battle()
	{
		// create user's and AI's areas
		Area userArea = new Area();
		Map map1 = new Map(50, 50);
		map1.enableLocatingMode();
		userArea.setMap(map1);
		
		Area AIArea = new Area();
		Map map2 = new Map(690, 50);
		AIArea.setMap(map2);
		AIArea.isAI(true);
		
		areas.add(userArea);
		areas.add(AIArea);
                
                stats = Statistics.getInstance();
	}

	public static boolean isFinished()
	{
		return Battle.getInstance().isFinished;
	}
	
	public void setIsFinished(boolean status)
	{
		if (status == true)
		{
			areas.get(0).getMap().block();
			areas.get(1).getMap().block();
		}
		
		isFinished = status;
	}
	
	public ArrayList<Area> getAreas()
	{
		return areas;
	}
	
	public static Battle getInstance()
	{
		if (instance == null)
		{
			instance = new Battle();
		}
		
		return instance;
	}
	
	public void start()
	{
		areaUnderAttack = 1; 
		Control.getInstance().startBattle();
		areas.get(0).getMap().enableWarMode();
		areas.get(1).getMap().enableWarMode();
		
		Area area = areas.get(areaUnderAttack);
	
		//Control.getInstance().enableArea();
	}
}